#ifndef COMMON_H
#define COMMON_H

//Common typedefs
typedef unsigned long	u64int;
typedef long			s64int;
typedef	unsigned int	u32int;
typedef	int				s32int;
typedef unsigned short	u16int;
typedef short			s16int;
typedef unsigned char	u8int;
typedef char			s8int;

//Basic memory management
//void map_memory(memory_map_t *ptr, int length);
void *memset(void *s, int c, int n);

//Basic I/O bus communication
unsigned char inportb (unsigned short _port);
void outportb (unsigned short _port, unsigned char _data);

//print.c: text mode 0 printing
char * itoa( int value, int base );
void print(char *c);
void print_char(unsigned char c);
void print_col(char *c, unsigned char col);
void print_char_col(unsigned char c, unsigned char col);
void clear_screen();
void scroll_screen();
char is_newline();
void print_OK();
void print_ERR();

//isrs.c: Exceptions
struct regs
{
    unsigned int gs, fs, es, ds;      /* pushed the segs last */
    unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;  /* pushed by 'pusha' */
    unsigned int int_no, err_code;    /* our 'push byte #' and ecodes do this */
    unsigned int eip, cs, eflags, useresp, ss;   /* pushed by the processor automatically */ 
};
void init_isrs();
void fault_handler(struct regs *r);

//irq.c: Interrupt Requests
void init_irq();
void irq_install_handler(int irq, void (*handler)(struct regs *r));
void irq_uninstall_handler(int irq);

//idt.c: Interrupt Descriptor Table
void init_idt();
void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);

//gdt.c: Global Descriptor Table
void init_gdt();

//timer.c: Timer to do stuff periodically
void init_timer();
void timer_sleep(int ticks);

//keyboard.c: Keyboard handler
void init_keyboard();

void init_mman();

#endif
